package com.quyeying.service.impl;

import com.quyeying.entity.TblProductExtendEntity;
import com.quyeying.mapper.TblProductExtendDao;
import com.quyeying.service.TblProductExtendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.quyeying.utils.result.R;
import com.quyeying.utils.result.ReturnPageData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
* <p>
 * 商品扩展表 服务实现类
 * </p>
*
* @author skx
* @since 2022-10-19
*/
@Service
public class TblProductExtendServiceImpl extends ServiceImpl<TblProductExtendDao, TblProductExtendEntity> implements TblProductExtendService {

    @Override
    public R findListByPage(Integer page, Integer pageCount){
        IPage<TblProductExtendEntity> wherePage = new Page<>(page, pageCount);
        TblProductExtendEntity where = new TblProductExtendEntity();
        IPage<TblProductExtendEntity> iPage = baseMapper.selectPage(wherePage, Wrappers.query(where));
        return R.success(ReturnPageData.fillingData(iPage));
    }

    @Override
    public R add(TblProductExtendEntity tblProductExtendEntity){
        baseMapper.insert(tblProductExtendEntity);
        return R.success();
    }

    @Override
    public R delete(Long id){
        baseMapper.deleteById(id);
        return R.success();
    }

    @Override
    public R updateData(TblProductExtendEntity tblProductExtendEntity){
        baseMapper.updateById(tblProductExtendEntity);
        return R.success();
    }

    @Override
    public R findById(Long id){
        TblProductExtendEntity tblProductExtendEntity = baseMapper.selectById(id);
        return R.success(tblProductExtendEntity);
    }
}
